package com.demo.deal_service.enums;

import org.springframework.http.HttpStatus;

/**
 * 返回结果的枚举
 */
public enum ResultEnum {
    /*
      删除相关
     */
    DEAL_DELETE_SUCCESS("SUC_701", "DEAL_DELETE_SUCCESS", HttpStatus.OK, "删除成功:{%s}"),
    DEAL_DELETE_FAIL_CHECK("FAIL_702", "DEAL_DELETE_FAIL_CHECK", HttpStatus.BAD_REQUEST, "业务检查失败：{%s}"),

    /*
      插入相关
     */
    DEAL_ADD_SUCCESS("SUC_201", "DEAL_ADD_SUCCESS", HttpStatus.OK, "添加成功:{%s}"),
    DEAL_ADD_FAIL_CHECK("FAIL_201", "DEAL_ADD_FAIL_CHECK", HttpStatus.BAD_REQUEST, "业务检查失败：{%s}"),
    DEAL_ADD_FAIL_UPLOAD("FAIL_202", "DEAL_ADD_FAIL_UPLOAD", HttpStatus.BAD_REQUEST, "上传文件失败：{%s}"),

    /*
    */
    DEAL_ORDER_SUCCESS("SUC_201", "DEAL_ORDER_SUCCESS", HttpStatus.OK, "下单成功:{%s}"),
    DEAL_ORDER_FAIL_CHECK("FAIL_201", "DEAL_ORDER_FAIL_CHECK", HttpStatus.BAD_REQUEST, "业务检查失败：{%s}"),
    DEAL_ORDER_FAIL_UPLOAD("FAIL_202", "DEAL_ORDER_FAIL_UPLOAD", HttpStatus.BAD_REQUEST, "上传文件失败：{%s}"),

    /*
      异常相关
     */
    EXC_DB("EXC_001", "EXC_DB", HttpStatus.INTERNAL_SERVER_ERROR, "数据库异常：{%s}"),
    EXC_REMOTE("EXC_002", "EXC_REMOTE", HttpStatus.INTERNAL_SERVER_ERROR, "远程调用异常：{%s}"),
    EXC_ELSE("EXC_009", "EXC_ELSE", HttpStatus.INTERNAL_SERVER_ERROR, "其他异常：{%s}"),;

    private String code;//编号

    private String name;//名称

    private HttpStatus httpStatus;//http状态码

    private String msgPattern;//返回消息的样式

    ResultEnum(String code, String name, HttpStatus httpStatus, String msgPattern) {
        this.code = code;
        this.name = name;
        this.httpStatus = httpStatus;
        this.msgPattern = msgPattern;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public HttpStatus getHttpStatus() {
        return httpStatus;
    }

    public String getMsgPattern() {
        return msgPattern;
    }
}